package com.example.test.主方法运行测试;


import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.example.test.bean.AreaChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collectors;

@Slf4j
public class Main1 {


    /**
     * @param args
     */
    public static void main(String[] args) {

        String MSG = "[{\"hasAuth\":true,\"serialNumber\":\"5\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":1,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"192.168.116.254\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18005\",\"channelId\":\"1417784179520811013\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"6\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34022827771310000006\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18006\",\"channelId\":\"1417784179533393922\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"8\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34023717101310000008\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18008\",\"channelId\":\"1417784179533393924\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"7\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34025751851310000007\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18007\",\"channelId\":\"1417784179533393923\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"13\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34027924391310000013\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-180013\",\"channelId\":\"1417784179533393929\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"1\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":1,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"192_168_116_131\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18001\",\"channelId\":\"1417784179520811009\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"10\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34022282751310000010\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-180010\",\"channelId\":\"1417784179533393926\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"9\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34021692381310000009\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18009\",\"channelId\":\"1417784179533393925\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"14\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34022367081310000014\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-180014\",\"channelId\":\"1417784179533393930\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"0\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":1,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"192.168.116.151\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18000\",\"channelId\":\"1417784179512422401\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"3\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":1,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"192.168.116.179\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18003\",\"channelId\":\"1417784179520811011\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"12\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34027838521310000012\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-180012\",\"channelId\":\"1417784179533393928\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"4\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":1,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"192.168.116.241\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18004\",\"channelId\":\"1417784179520811012\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"11\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34025418101310000011\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-180011\",\"channelId\":\"1417784179533393927\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"2\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":1,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"192.168.116.235\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-18002\",\"channelId\":\"1417784179520811010\",\"longitude\":\"\"},{\"hasAuth\":true,\"serialNumber\":\"15\",\"channelDeviceName\":\"华为-1800\",\"hasMapPoint\":false,\"channelAreaId\":\"1405355639076679681\",\"latitude\":\"\",\"channelStatus\":0,\"permission\":\"live_preview,video_replay,ptz_control,voice_intercom,decode_to_wall,remote_config,env_collect\",\"channelClassify\":\"1\",\"channelBusinessType\":\"business_video\",\"channelDeviceType\":\"3\",\"realName\":\"34024765851310000015\",\"supportAbility\":\"\",\"areaName\":\"国标\",\"channelEnabled\":true,\"channelDeviceSn\":\"34020000001180000126\",\"addingMethod\":\"3\",\"channelDeviceId\":\"1417784178962968577\",\"channelName\":\"华为-180015\",\"channelId\":\"1417784179562754049\",\"longitude\":\"\"}]\n";
//
        String s = JSONUtil.toJsonStr(MSG);
//
        JSONArray jsonArray = JSONUtil.parseArray(s);
//
        List<AreaChannel> areaChannels = JSONUtil.toList(jsonArray, AreaChannel.class);
//
        List<AreaChannel> collect = areaChannels.stream()
                .sorted(Comparator.comparingInt(AreaChannel::getSerialNumber)).collect(Collectors.toList());
//        System.out.println(JSONUtil.toJsonStr(areaChannels));
//        System.out.println(JSONUtil.toJsonStr(collect));
//        System.out.println("111111");

        areaChannels.stream().filter(new Predicate<AreaChannel>() {
            @Override
            public boolean test(AreaChannel areaChannel) {
                return new ConcurrentHashMap<>().putIfAbsent(areaChannel.getChannelAreaId(), "true") == null;
            }
        }).collect(Collectors.toList());


//        int i = 0;
//
//        while (i < 10) {
//            i++;
//            System.out.println("111");
//            if (5==i) {
//                break;
//            }
//        }
//        System.out.println("222");

//        String random = StringUtils.unqualify("1:2:3", ':');
//
//        System.out.println(random);


        String aa = "下瓦房街福至里居街福至里居家养街福至里居家养街福至里居家养老服务中心下瓦房街福至里居家养老服务中心下瓦房街福至里居家养老服务中心";
        System.out.println(aa.substring(0, 63).length());


    }


}
